<?php
/**
 * run with command
 * php start.php start
 */
ini_set('display_errors', 'on');

// 检查扩展
if (!extension_loaded('pcntl')) {
    exit("Please install pcntl extension. See http://doc3.workerman.net/install/install.html\n");
}
if (!extension_loaded('posix')) {
    exit("Please install posix extension. See http://doc3.workerman.net/install/install.html\n");
}
// 标记是全局启动
define('GLOBAL_START', 1);
defined('ROOTPATH') or define('ROOTPATH', __DIR__);
defined('LOGSPATH') or define('LOGSPATH', ROOTPATH . '/logs');
/** 设置区时 */
date_default_timezone_set('PRC');

require ROOTPATH . '/vendor/autoload.php';

Workerman\Worker::$pidFile = LOGSPATH . '/pid';
Workerman\Worker::$logFile = LOGSPATH . '/workerman.log';

// 加载所有app/start.php，以便启动所有服务
foreach (glob(ROOTPATH . '/app/*/start*.php') as $start_file) {
    require_once $start_file;
}

// 运行所有服务
Workerman\Worker::runAll();
